<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>02_外间距测试</title>
</head>
<style>
    /* 去除body自带的8px 外边距*/
    body {
        margin: 0;
    }
    /* 去除所有元素自带的内外边距*/
    * {
        padding: 0;
        margin: 0;
    }
    .fu {
        background-color: rgba(255,255,0,.3);
        /* 2. 父子贴边：首个子元素的上边和最后一个子元素的下边 设置间距时会超出父元素的范围
        解决：给父元素设置BFC结界保护*/
        overflow: hidden;
    }
    .fu>div {
        width: 100px;
        height: 100px;
        background-color: rgba(0,0,255,.6);
        border: 2px solid #00f;
        color: #fff;
        font-size: 25px;
        font-weight: bold;
    }
    .z1 {
        margin-bottom: 30px;
        margin-top: 50px;
    }
    .z2 {
        margin-top: 50px;
    }
    .z4 {
        margin-bottom: 50px;
    }
    .z3 {
        margin: 10px;
        margin: 10px 20px;
        margin: 10px 20px 30px;
        margin: 10px 20px 30px 40px;
        /* 只能设置块级元素 */
        margin: 0 auto;
    }
    span {
        border: 2px solid #f00;
    }
    .s2 {
        /* 行内元素垂直方向上的外间距不生效！*/
        margin: 30px;
    }
</style>
<body>
<span>span1</span><span class="s2">span2</span><span>span3</span>
    <!--
    .fu>.z*3
    生成class为fu的div，里面有3个class为z的div
    -->
    <div class="fu">
        <div class="z1">子元素1</div>
        <div class="z2">子元素2</div>
        <div class="z3">子元素3</div>
        <div class="z4">子元素4</div>
    </div>
</body>
</html>